package com.wwwarehouse.usercenter.fragment.business_relationship;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.wwwarehouse.common.bean.response.CardDeskFunctionResponseBean;
import com.wwwarehouse.common.constant.Constant;
import com.wwwarehouse.common.custom_widget.ElasticScrollView;
import com.wwwarehouse.common.tools.PopUpUtils;
import com.wwwarehouse.usercenter.R;
import com.wwwarehouse.usercenter.constant.UserCenterConstant;
import com.wwwarehouse.usercenter.fragment.invite.ShowInvitedFragment;

import java.util.HashSet;
import java.util.Set;

/**
 * 添加业务伙伴
 * Created by xiaoke.ni on 2017/10/21.
 */

public class BRAddFriendsFragment extends ShowInvitedFragment {

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mElasticScrollView.setOnPullListener(new ElasticScrollView.OnPullListener() {
            @Override
            public void onDownPull() {

            }

            @Override
            public void onUpPull() {

            }
        });
    }

    @Override
    public void sortClick(View anchor) {
        if (peekFragment() instanceof BRAddFriendsFragment) {
            PopUpUtils.showBubbleInviteSort(mActivity, anchor, mSelectedBubblePosition, new PopUpUtils.OnChoiceListener() {
                @Override
                public void onChoice(int position) {
                    mSelectedBubblePosition = position;
                    switch (position) {
                        case 2:
                            mSort = "INVALID_TIME";        //邀请时间正序
                            break;
                        case 3:
                            mSort = "INVALID_TIME DESC ";  //邀请时间倒序
                            break;
                        default:
                            break;
                    }

                    getInviteInfo(mMobile, mName, mStatusSet, mSort);
                }
            },"",getString(R.string.user_br_time_asc),getString(R.string.user_br_time_desc));
        }
    }

    /**
     * 	buId	业务单位ID
     * taskTypeUkid	任务类型UKID
     */
    @Override
    public void newFragment(int i) {
        super.newFragment(i);
        String relationType = getArguments().getString("relationType");
        /**************** 1130 ****************/
        mBundle.putString("buId", getArguments().getString("buId"));
        mBundle.putString("taskTypeUkid", getArguments().getString("taskTypeUkid"));
        /**************** 1030 ****************/
//        CardDeskFunctionResponseBean.TaskBean taskDetailsBean = (CardDeskFunctionResponseBean.TaskBean) getArguments().getSerializable(Constant.KEY_CARD_DESK_FUNCTION_DETAILS);
//        mBundle.putString("buId", taskDetailsBean.getBusinessId());
//        mBundle.putString("taskTypeUkid", taskDetailsBean.getTaskTypeUkid());

        if(relationType == null)
            mBundle.putString("relationType", "CUSTOMER");
        else
            mBundle.putString("relationType", getArguments().getString("relationType"));
    }

    @Override
    protected void newFragment() {
        mInviteDetailsFragment = new BRAddFriendsListFragment();
    }

    @Override
    protected Set<Integer> generateStatusSet() {
        Set<Integer> statusSet = new HashSet<>();
        statusSet.add(10);

        return statusSet;
    }

    @Override
    public void setTitle() {
        if (peekFragment() instanceof BRAddFriendsFragment) {
            mActivity.setTitle(getString(R.string.user_br_add_friends));
        }
    }
}
